<!--
  @author heguanghua
  @since 2019/06/12 11:57
-->
<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-4.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head th:include="common/common::jscss"/>
<body
th:with="hasRequiredFinancer=${obj.accessIdentity != null && #strings.contains(obj.accessIdentity, '2')},hasRequired=${obj.rank == 2}">

<div class="layui-fluid">

    <blockquote class="layui-crumb">
        渠道管理>
        <a lay-href="/channel/list.action">渠道管理</a>>
        <a th:href="'/channel/detail.action?channelId='+${obj.channelId}">[[${obj.name}]]</a>>
        <zmn text="结算信息">结算信息</zmn>
    </blockquote>

    <div class="layui-card">

        <div th:replace="channel/_tab::tab"></div>

        <fieldset class="layui-elem-field">
            <div th:if="${obj.rank == 2}" class="layui-field-box" style="color: #9F9F9F;">
                未配置，走上级一级渠道配置
            </div>
        </fieldset>

        <div class="layui-card-body">

            <form method="POST" action="" class="layui-form" lay-filter="zmn-form">

                <input type="hidden" name="channelId" th:value="${obj.channelId}"/>
                <input type="hidden" name="plat" th:value="${obj.plat}"/>

                <div class="layui-card-header layui-margin-b"><b>渠道结算</b></div>

                <div class="layui-form-item">
                    <label class="layui-form-label layui-form-required">结算周期：</label>
                    <div class="layui-input-inline" style="width:300px">
                        <select lay-filter="statementMode" name="statementMode" lay-search th:lay-verify="${hasRequired ? 'required' : ''}">
                            <option value=""></option>
                            <option th:each="statementMode:${statementModes}" th:value="${statementMode.value}" th:selected="${statementMode.value == channelSettle.statementMode}" th:text="${statementMode.text}"/>
                        </select>
                    </div>
                    <span class="layui-form-label" style="width: auto; color: #9F9F9F;">&nbsp;&nbsp;渠道订单佣金和渠道代收款的结算周期一致</span>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label layui-form-required">结算生成日期：</label>
                    <div class="layui-input-inline" style="width:300px">
                        <select id="statementGenerateTime" name="statementGenerateTime" lay-search th:lay-verify="${hasRequired ? 'required' : ''}">
                        </select>
                    </div>
                    <div id="statementGenerateTimeSecondDiv" class="layui-input-inline" th:style="|width:300px;${channelSettle.statementMode == 4 ? '' : 'display:none'}|">
                        <select id="statementGenerateTimeSecond" name="statementGenerateTimeSecond" lay-search>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label layui-form-required">结算截至日：</label>
                    <div class="layui-input-inline" style="width:300px">
                        <select id="statementEndTime" name="statementEndTime" lay-search th:lay-verify="${hasRequired ? 'required' : ''}">
                        </select>
                    </div>
                    <div id="statementEndTimeSecondDiv" class="layui-input-inline" th:style="|width:300px;${channelSettle.statementMode == 4 ? '' : 'display:none'}|">
                        <select id="statementEndTimeSecond" name="statementEndTimeSecond" lay-search>
                        </select>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label layui-form-required">结算节点：</label>
                    <div class="layui-input-inline" style="width:auto">
                        <input lay-filter="statementNode" type="radio" lay-verify="nodeRequired" name="statementNode" value="1" title="完成"
                               th:checked="${channelSettle.statementNode == 1}" th:disabled="${channelSettle.statementNode != null}">
                        <input lay-filter="statementNode" type="radio" lay-verify="nodeRequired" name="statementNode" value="2" title="领单"
                               th:checked="${channelSettle.statementNode == 2}" th:disabled="${channelSettle.statementNode != null}">
                    </div>
                    <span class="layui-form-label" style="width: auto; color: #9F9F9F;">&nbsp;&nbsp;领单节点指：家修匠工程师曾经领单过或分单至非家修匠公司；选择后，不可更改，请认真选择</span>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label layui-form-required">结算渠道：</label>
                    <div class="layui-input-inline" style="width:auto">
                        <input lay-filter="statementChannel" type="radio" lay-verify="channelRequired" name="statementChannel" value="1" title="下单渠道"
                               th:checked="${channelSettle.statementChannel == 1}">
                        <input lay-filter="statementChannel" type="radio" lay-verify="channelRequired" name="statementChannel" value="2" title="来源渠道"
                               th:checked="${channelSettle.statementChannel == 2}">
                    </div>
                    <span class="layui-form-label" style="width: auto; color: #9F9F9F;">&nbsp;&nbsp;来源渠道指：该渠道根据来源渠道结算</span>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label layui-form-required">合并结算：</label>
                    <div class="layui-input-inline" style="width:auto">
                        <input lay-filter="mergeSettle" type="radio" lay-verify="mergeRequired" name="mergeSettle" value="2" title="是"
                               th:checked="${channelSettle.mergeSettle == 2}" th:default="1">
                        <input lay-filter="mergeSettle" type="radio" lay-verify="mergeRequired" name="mergeSettle" value="1" title="否"
                               th:checked="${channelSettle.mergeSettle == 1}">
                    </div>
                    <span style="width: auto; color: #9F9F9F;">
                        &nbsp;&nbsp;合并结算指："结算信息"&结算主体一致的渠道，分别计算出结算金额汇总后统一进行结算<br/>
                        &nbsp;&nbsp;结算信息包含：结算周期、结算起始时期、结算截至时期、合并结算字段
                    </span>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label layui-form-required">开发票方：</label>
                    <div class="layui-input-inline" style="width:auto">
                        <input lay-filter="writeInvoiceParty" type="radio" lay-verify="mergeRequired"
                               name="writeInvoiceParty" value="1" title="啄木鸟"
                               th:checked="${ channelSettle.writeInvoiceParty == null || channelSettle.writeInvoiceParty == 1 }">
                        <input lay-filter="writeInvoiceParty" type="radio" lay-verify="mergeRequired"
                               name="writeInvoiceParty" value="2" title="渠道"
                               th:checked="${channelSettle.writeInvoiceParty == 2}">
                    </div>
                    <span style="width: auto; color: #9F9F9F;">
                        &nbsp;&nbsp;开发票方指：给用户开发票；若开票方选择渠道方，用户在微信公众号/小程序端无申请开发票入口
                    </span>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label layui-form-required">渠道方财务对接人/电话：</label>
                    <div
                            class="layui-input-inline"
                            style="width:300px">
                        <input
                                type="text"
                                name="financer"
                                th:value="${channelSettle.financer}"
                                placeholder="渠道方财务对接人"
                                lay-verify="required"
                                lay-verType="tips"
                                autocomplete="off"
                                class="layui-input"
                                maxlength="20"
                        />
                    </div>
                    <div class="layui-input-inline" style="width:300px">
                        <th:block th:switch="${#authPermit.checkPermit('/channel/showMobile.action')}">
                            <div th:case="true">
                                <input
                                        type="text"
                                        name="financerPhone"
                                        id="financerPhone"
                                        th:value="${channelSettle.financerPhone}"
                                        placeholder="联系电话"
                                        lay-verify="required|telphone"
                                        lay-verType="tips"
                                        autocomplete="off"
                                        class="layui-input"
                                        maxlength="11"
                                        onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')"
                                />
                            </div>
                            <div th:case="*">
                                <input
                                        type="text"
                                        name="financerPhone"
                                        id="financerPhone"
                                        th:value="${T(com.zmn.plat.common.util.ChannelUtil).hideString(channelSettle.financerPhone,null,null,null,null)}"
                                        placeholder="联系电话"
                                        lay-verify="required|telphone"
                                        lay-verType="tips"
                                        autocomplete="off"
                                        class="layui-input"
                                        maxlength="11"
                                        onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')"
                                />
                            </div>

                    </div>
                </div>

                <div class="layui-card-header layui-margin-b"><b>银行卡账户</b></div>

                <!--<div class="layui-form-item">-->
                <!--<label class="layui-form-label">银行：</label>-->
                <!--<div class="layui-input-inline" style="width:300px">-->
                <!--<input type="text" name="bankName" th:value="${channelSettle.bankName}" placeholder="银行" lay-verify="required" lay-verType="tips" autocomplete="off" class="layui-input" maxlength="45"/>-->
                <!--</div>-->
                <!--</div>-->

                <div class="layui-form-item">
                    <label class="layui-form-label">开户行：</label>
                    <div class="layui-input-inline" style="width:300px">
                        <input type="text" name="bankBranch" th:value="${channelSettle.bankBranch}" placeholder="开户行" lay-verify="" lay-verType="tips" autocomplete="off" class="layui-input" maxlength="45"/>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">银行卡号：</label>
                    <div class="layui-input-inline" style="width:300px">
                        <th:block th:switch="${#authPermit.checkPermit('/channel/settle/showBankCard.action')}">
                            <div th:case="true">
                                <input type="text" name="bankAccount" id="bankAccount" th:value="${channelSettle.bankAccount}" placeholder="银行卡号" lay-verify="bankAccount" lay-verType="tips" autocomplete="off" class="layui-input" maxlength="45"  onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')"/>
                            </div>
                            <div th:case="*">
                                <input type="text" name="bankAccount" id="bankAccount" th:value="${T(com.zmn.plat.common.util.ChannelUtil).hideString(channelSettle.bankAccount,null,null,null,null)}" placeholder="银行卡号" lay-verify="bankAccount" lay-verType="tips" autocomplete="off" class="layui-input" maxlength="45"  onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')"/>
                            </div>
                        </th:block>

                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">户名：</label>
                    <div class="layui-input-inline" style="width:300px">
                        <input type="text" name="accountName" th:value="${channelSettle.accountName}" placeholder="户名" lay-verify="" lay-verType="tips" autocomplete="off" class="layui-input" maxlength="45"/>
                    </div>
                </div>

                <div class="layui-card-header layui-margin-b"><b>支付宝账户</b></div>
                <div class="layui-form-item">
                    <label class="layui-form-label">姓名：</label>
                    <div class="layui-input-inline" style="width:300px">
                        <input type="text" name="alipayName" th:value="${channelSettle.alipayName}" placeholder="姓名" lay-verify="" lay-verType="tips" autocomplete="off" class="layui-input" maxlength="45"/>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">支付宝账号：</label>
                    <div class="layui-input-inline" style="width:300px">
                        <th:block th:switch="${#authPermit.checkPermit('/channel/settle/showAliAccount.action')}">
                            <div th:case="true">
                                <input type="text" name="alipayAccount" id="alipayAccount" th:value="${channelSettle.alipayAccount}" placeholder="支付宝账号" lay-verify="" lay-verType="tips" autocomplete="off" class="layui-input" maxlength="45" onkeyup="this.value=this.value.replace(/[*]/g,'')" onafterpaste="this.value=this.value.replace(/[*/g,'')"/>
                            </div>
                            <div th:case="*">
                                <input type="text" name="alipayAccount" id="alipayAccount"  th:value="${T(com.zmn.plat.common.util.ChannelUtil).hideString(channelSettle.alipayAccount,null,null,null,null)}" placeholder="支付宝账号" lay-verify="" lay-verType="tips" autocomplete="off" class="layui-input" maxlength="45" onkeyup="this.value=this.value.replace(/[*]/g,'')" onafterpaste="this.value=this.value.replace(/[*]/g,'')"/>
                            </div>
                        </th:block>

                    </div>
                </div>

                <div class="layui-card-header layui-margin-b"><b>微信账户</b></div>

                <div class="layui-form-item">
                    <label class="layui-form-label">姓名：</label>
                    <div class="layui-input-inline" style="width:300px">
                        <input type="text" name="wechatName" th:value="${channelSettle.wechatName}" placeholder="姓名" lay-verify="" lay-verType="tips" autocomplete="off" class="layui-input" maxlength="45"/>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">微信账号：</label>
                    <div class="layui-input-inline" style="width:300px">
                        <th:block th:switch="${#authPermit.checkPermit('/channel/settle/showWechatAccount.action')}">
                            <div th:case="true">
                                <input type="text" name="wechatAccount" id="wechatAccount" th:value="${channelSettle.wechatAccount}" placeholder="微信账号" lay-verify="" lay-verType="tips" autocomplete="off" class="layui-input" maxlength="45" onkeyup="this.value=this.value.replace(/[*]/g,'')" onafterpaste="this.value=this.value.replace(/[*]/g,'')"/>
                            </div>
                            <div th:case="*">
                                <input type="text" name="wechatAccount" id="wechatAccount"  th:value="${T(com.zmn.plat.common.util.ChannelUtil).hideString(channelSettle.wechatAccount,null,null,null,null)}" placeholder="微信账号" lay-verify="" lay-verType="tips" autocomplete="off" class="layui-input" maxlength="45"  onkeyup="this.value=this.value.replace(/[*]/g,'')" onafterpaste="this.value=this.value.replace(/[*]/g,'')"/>
                            </div>
                        </th:block>

                    </div>
                </div>

<!--                <div class="layui-card-header layui-margin-b"><b>工程师维修费结算规则</b></div>-->

<!--                <div class="layui-form-item">-->
<!--                    <label class="layui-form-label layui-form-required">结算规则：</label>-->
<!--                    <div class="layui-input-inline" style="width:300px">-->
<!--                        <input lay-verify="required" type="radio" name="financialRules" value="2" title="权责发生制"-->
<!--                               th:checked="${channelSettle.financialRules == 2 || channelSettle.financialRules == null ||  channelSettle.financialRules == 0}">-->
<!--                        <input lay-verify="required" type="radio" name="financialRules" value="1" title="收付实现制"-->
<!--                               th:checked="${channelSettle.financialRules == 1}">-->
<!--                    </div>-->
<!--                </div>-->

<!--                <div class="layui-form-item">-->
<!--                    <label class="layui-form-label"></label>-->
<!--                    <span class="layui-form-label" style="width: auto; color: #9F9F9F;">权责发生制下，平台在未收到渠道代收款的情况下，订单算账后即可给工程师结算该订单的维修费；收付实现制下，则必须收到渠道的代收款后才可给工程师结算。</span>-->
<!--                </div>-->

                <div class="layui-card-header layui-margin-b"><b>订单成本费用</b></div>

                <div class="layui-form-item">
                    <label class="layui-form-label">推广服务费：</label>
                    <div class="layui-input-inline" style="width:300px">
                        <input lay-verify="isEffectivePrice" lay-verType="tips" type="text" name="promotionServiceFee" th:value="${channelSettle.promotionServiceFeeYuan}" autocomplete="off" class="layui-input"/>
                    </div>
                    <div class="layui-input-inline" style="width:210px;">
                        <label class="layui-form-mid layui-word-aux">元/单&nbsp;&nbsp;&nbsp;&nbsp;用于订单经营分析报表</label>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">获客成本：</label>
                    <div class="layui-input-inline" style="width:auto">
                        <input lay-filter="customerCostMode" type="radio" name="customerCostMode" value="1" title="按实际导入"
                               th:checked="${channelSettle.customerCostMode == 1}">
                        <input lay-filter="customerCostMode" type="radio" name="customerCostMode" value="2" title="按固定金额"
                               th:checked="${channelSettle.customerCostMode == 2}">
                        <input lay-filter="customerCostMode" type="radio" name="customerCostMode" value="3" title="按比例"
                               th:checked="${channelSettle.customerCostMode == 3}">
                    </div>
                    <span class="layui-form-label" style="width: auto; color: #9F9F9F;">&nbsp;&nbsp;按实际导入，通过渠道单量成本报表中导入</span>
                </div>

                <div class="layui-form-item" id="customerCostDiv" th:style="${channelSettle.customerCostMode != null && channelSettle.customerCostMode == 2 ? '' : 'display: none'}">
                    <label class="layui-form-label">获客成本金额：</label>
                    <div class="layui-input-inline" style="width:300px">
                        <input lay-verify="isEffectivePrice" lay-verType="tips" type="text" id="customerCost" name="customerCost" th:value="${channelSettle.customerCostYuan}" autocomplete="off" class="layui-input"/>
                    </div>
                    <div class="layui-input-inline" style="width: 60px;padding-top: 7px;padding-bottom: 7px;color: #999 !important;">元/单</div>
                </div>

                <div class="layui-form-item" id="customerCostPercentDiv" th:style="${channelSettle.customerCostMode != null && channelSettle.customerCostMode == 3 ? '' : 'display: none'}">
                    <label class="layui-form-label">获客成本比例：</label>
                    <div class="layui-input-inline" style="width:300px">
                        <input lay-verify="isEffectivePercent" lay-verType="tips" type="text" id="customerCostPercent" name="customerCostPercent" th:value="${channelSettle.customerCostPercent}" autocomplete="off" class="layui-input"/>
                    </div>
                    <div class="layui-input-inline" style="width: 60px;padding-top: 7px;padding-bottom: 7px;color: #999 !important;">%/单</div>
                </div>

                <div class="layui-card-header layui-margin-b"><b>服务费</b></div>

                <div class="layui-form-item">
                    <label class="layui-form-label">综合服务费：</label>
                    <div class="layui-input-inline" style="width:300px">
                        <input lay-verify="isEffectivePrice" lay-verType="tips" type="text" name="comprehensiveServiceFee" th:value="${channelSettle.comprehensiveServiceFee == null ? '6.5': channelSettle.comprehensiveServiceFeeYuan}" autocomplete="off" class="layui-input"/>
                    </div>
                    <div class="layui-input-inline" style="width:210px;">
                        <label class="layui-form-mid layui-word-aux">元/单&nbsp;&nbsp;&nbsp;&nbsp;用于订单经营分析报表</label>
                    </div>
                </div>

                <div class="layui-form-item submit" th:if="${#authPermit.checkPermit('/channel/settle/addEdit.action') || (#authPermit.checkPermit('/channel/add.action') && addFlag == '1')}">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit="" lay-filter="zmn-form-submit">提交</button>
                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    </div>
                </div>

            </form>

        </div>

    </div>

</div>
</body>
</html>

<script type="text/javascript" th:inline="javascript">

    var json = {
        obj: [[${obj}]],
        addFlag: [[${addFlag}]],
        channelSettle: [[${channelSettle}]],
        weeks: [[${weeks}]],
        days: [[${days}]],
    };

    layui.config({
        base: "/static/lay/",
        version: 202006231641
    }).extend({
        index: "lib/index",
        channel_settle: "channel/zmn.plat.channel.settle",
    }).use(['index', 'channel_settle']);

</script>
